package com.service.Impl;

import com.dao.AdminDao;
import com.dao.UserDao;
import com.entity.Admin;
import com.entity.User;
import com.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminDao adminDao;
    @Autowired
    private UserDao userDao;

    /**
     * 管理员登录
     *
     * @param admin
     * @return
     */
    public Admin adminLogin(Admin admin) {
        Admin result = adminDao.adminLogin(admin);
        if (result != null) {
            return result;
        }
        return null;
    }

    public List<User> adminListUser() {
        return adminDao.adminListUser();
    }

    @Override
    public List<User> adminGetUserlist(int start, int count) {   //获取用户list
        List<User> users = new ArrayList<>();
        users = adminDao.adminGetUserlist(start, count);
        return users;
    }

    @Override
    public Integer adminGetUserTotal() {
        return adminDao.adminGetUserTotal();
    }  //获取用户总数


    public void adminDelUser(User user) {
        adminDao.adminDelUser(user);
    } //删除用户


    public void adminAddUser(User user) {
        adminDao.adminAddUser(user);
    } //添加用户


    public void adminAuditStatus(User user) { adminDao.adminAuditStatus(user); } //管理员解封用户


    public void adminBanStatus(User user) { adminDao.adminBanStatus(user); } //管理员封禁用户


}
